package com.cgc.game.base.ui;

import com.cgc.game.base.interfacer.IInput;
import com.cgc.game.base.interfacer.IItem;

public  class Item  implements IInput,IItem{
	
//	private boolean active = false;
	private int key = 0;
	private int state = 0;
	public int cmd = 0;
	public DisplayObject obj;
	
	public Item(DisplayObject obj,int keycode,int cmdId) {
		this.obj = obj;
		this.key = keycode;
		this.cmd = cmdId;
	}
	public Item(DisplayObject obj,int keycode,int cmdId,int state) {
		this.obj = obj;
		this.key = keycode;
		this.cmd = cmdId;
		this.state = state;
	}
	
	public boolean onKey(int keyCode,int action)
	{
		if(obj instanceof IInput) {
				return ((IInput) obj).onKey(keyCode, action);
		}
		if(key == keyCode) return true;
		return false;
	}
	
	public void setState(int state)
	{
		this.state = state;
		if(obj instanceof IItem)
		{
			((IItem) obj).setState(state);
		}
	}
	
	public int getState()
	{
		return state;
	}
	
//	public boolean isActive() {
//		return active;
//	}
//	
//	public void setActive(boolean active) {
//		this.active = active;
//	}
}
